﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class News_NewsDetail : System.Web.UI.Page
{
    _dbDataContext _db = new _dbDataContext();
    public SecurityLib.Sec_AES _ps = new SecurityLib.Sec_AES();
    public tblNew news = new tblNew();
    public List<tblNew> toplist = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string id = _ps.Decrypt(Request.QueryString["newsid"].Replace(" ", "+"), "gold", 128);
            string donvi=MemberShip_ASP.GetMaDonViFromUserName(this.Page.User.Identity.Name);
            news = _db.tblNews.Single(r => r.ID == int.Parse(id));
            toplist = _db.tblNews.Where(r => r.tblAcount.DonVi == donvi && r.ID != int.Parse(id)).OrderByDescending(r => r.ID).Skip(0).Take(5).ToList();
            if (!news.DaDoc.Contains(donvi))//neu da doc khong chua don vi hien tai thi update vao
            {
                news.DaDoc = news.DaDoc + ";" + MemberShip_ASP.GetMaDonViFromUserName(this.Page.User.Identity.Name);
                try
                {
                    _db.SubmitChanges();
                }
                catch { }
            }
        }
    }
}